package com.itheima.mapper;

import com.itheima.common.Com.Dish;
import com.itheima.common.Com.Flavors;
import com.itheima.common.vo.DishVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    List<DishVo> getList(@Param("categoryId") String categoryId);

    //添加dish的数据
    int save(@Param("dish") Dish dish);

    //添加Falors的数据                @param 就是给取个别名
    int saveFalors(@Param("flavors") Flavors flavors);

    boolean addflavors(Flavors flavors);

    int update(@Param("dish") Dish dish);

    int updateFalors(@Param("flavors") Flavors flavors);

    int delete(@Param("arrs")String [] arr);

    void discontinued(@Param("status") Integer status,@Param("lists") String [] list);


    long count(@Param("name") String name);


    List<Dish> getpage(@Param("name") String name,@Param("start")Integer start,
                       @Param("pageSize") Integer pageSize, @Param("type") Integer type);

   List<DishVo> getById(@Param("id") String id);

    void getByDishId(@Param("flavors") Flavors flavors);

    void deleteById(@Param("flavors") List<Flavors> flavors);

    void getByFlavors(@Param("flavors") Flavors flavors);

    List<Flavors> getByidFlavors(@Param("id") String  id);

    @Select("select * from dish where `id` =#{id}")
    Dish findbyid(String id);

    @Delete("delete from flavors where `dish_id`=#{id}")
    boolean deletebyid(String id);

    List<Dish> getAll(@Param("categoryId") String categoryId, @Param("status") Integer status
            , @Param("start") Integer start, @Param("pageSize") Integer pageSize);

//    String findbycategoryname(String categoryId);
}

